home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 039a / mawk10.zip / NOCOMMEN.AWK < prev    next >
Text File  |  1991-10-05  |  601b  |  31 lines

  1.  
  2. # remove C comments  from a list of files
  3. # using a comment as the record separator
  4. #
  5. # this is trickier than I first thought
  6. # The first version in .97-.9993 was wrong
  7.  
  8. BEGIN {
  9.  # RS is set to  a comment (this is mildly tricky, I blew it here
  10.  RS = "/\*([^*]|\*+[^*/])*\*+/"
  11.  ORS = " "
  12.  getline hold
  13.  filename = FILENAME
  14. }
  15.  
  16. # if changing files
  17. filename != FILENAME {
  18.   filename = FILENAME
  19.   printf "%s" , hold
  20.   hold = $0
  21.   next
  22. }
  23.  
  24. { # hold one record because we don't want ORS on the last
  25.   #  record in each file
  26.   print hold
  27.   hold = $0
  28. }
  29.  
  30. END { printf "%s", hold }
  31.